<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  // concat() 字符串拼接 (将多个字符或字符串拼接形成新字符串)
  // 返回 拼接后的新字符串   
  // 了解  一般还是还是习惯用 +

  // var str = "hello";
  // var result = str.concat(" ","everyone!"," ","good"," ","good"," ","study");

  // var result = str + " " + "everyone!" + " " + "good" + " "+ "good" + " " + "study!" 

  // console.log(result);


  // 字符串裁切的三个方法
  // slice(startIndex,endIndex)  字符串裁切
  // startIndex   默认0
  // endIndex     默认str.length

  var str = "good good study , day day up";
  var str1 = str.slice(10, 15);
  // var str1 = str.slice(5,25);  "good study , day day"
  console.log(str1);

  // slice() 可以接收负值作为参数  -3 => str.length-3
  var str1 = str.slice(5, -3);
  console.log(str1);

  // substring(startIndex,endIndex)  字符串裁切(同slice 但是不能接收负值)
  var str = "good good study , day day up";
  var str1 = str.substring(10, 15);
  console.log(str1);

  // substr(startIndex,length) 字符串裁切  从下标为startIndex的位置开始,裁切n个字符
  var str = "good good study , day day up";
  var str1 = str.substr(5, 4);
  console.log(str1);


</script>

</html>